20f90e7c593790622fea6dfbc282efe22960648d,src/dev/java/japsadev/bio/hts/newscarf/BidirectedGraph.java,BidirectedGraph,reduce,#BidirectedPath#,202

Before Change


    		BidirectedEdge e = (BidirectedEdge) startEdges.next();
    		BidirectedNode opNode = e.getOpposite(start);
    		boolean opDir = e.getDir(opNode);
    		addEdge(BidirectedEdge.createID(start, opNode, false, opDir), comp, opNode);//always into start node
    	}
    	
    	while(endEdges.hasNext()){

After Change


     */
    public void reduce(BidirectedPath p){
    	//do nothing if the path has only one node
    	if(p.getEdgeCount()<1)
    		return;
    	//add the new composite Node to the graph
    	//compare id from sense & anti-sense to get the unique one
    	AbstractNode comp = addNode(p.getId().compareTo(p.getReversedComplemented().getId())>0?
    								p.getReversedComplemented().getId():p.getId());
    	
    	comp.addAttribute("path", p);
    	comp.addAttribute("seq", p.spelling());
        comp.addAttribute("ui.label", comp.getId());
        comp.setAttribute("ui.style", "text-offset: -10;"); 
        comp.setAttribute("ui.class", "marked");
        try { Thread.sleep(100); } catch (Exception e) {}

    	//store unique nodes on p for removing
    	ArrayList<String> tobeRemoved=new ArrayList<String>();
    	for(Node n:p.getEachNode()){
    		if(isUnique(n))
    			tobeRemoved.add(n.getId());
    	}
    	BidirectedNode 	start = (BidirectedNode) p.getRoot(),
    					end = (BidirectedNode) p.peekNode();
    	boolean startDir = ((BidirectedEdge) p.getEdgePath().get(0)).getDir(start), 
    			endDir = ((BidirectedEdge) p.peekEdge()).getDir(end);
    	//set neighbors of the composite Node
    	Iterator<Edge> startEdges = startDir?start.getEnteringEdgeIterator():start.getLeavingEdgeIterator(),
    					endEdges = endDir?end.getEnteringEdgeIterator():end.getLeavingEdgeIterator();
    	while(startEdges.hasNext()){
    		BidirectedEdge e = (BidirectedEdge) startEdges.next();
    		BidirectedNode opNode = e.getOpposite(start);
    		boolean opDir = e.getDir(opNode);
    		Edge tmp=addEdge(BidirectedEdge.createID(comp, opNode, false, opDir), comp, opNode);//always into start node
    		System.out.println("From " + start.getId() + ": " + tmp.getId() + " added!");
    	}
    	
    	while(endEdges.hasNext()){